#include <iostream>
using namespace std;

//回文字符串的判断-递归
int recursion(char a[],int front,int ending) {

	if (a[front] != a [ending]){ 
		return 0;
	}
	if (front == ending|| front == ending - 1){ 
		return 1;
	}
	if (a[front] == a [ending]){
		return recursion(a,front + 1,ending - 1);
	}
}

//回文字符串的判断-递推
bool recurrence(char *c,int length){
   
   char *front = c;
   char *back = c + length -1;
   
   if (c==NULL||length<1){
   	return false;
   }
   while(front<back){
   	if (*front != *back){ // O(n)
   		return false;
   	}
   	front++;
   	back--;
   }
   
   return true;
}


int main(){
	char c[100];
	cout << "please input a char" << endl;
	cin >> c;
	int length = strlen(c);
	bool result = recurrence(c,length);
	if (result){
		cout << c << " is a palindrome" <<endl;
	}else{
		cout << c << " is not a palindrome" <<endl;
	}
	return 0;
}